#include <X11/Xlib.h>
#include <stdio.h>

int main(void) {
    Display *display;
    int screen; 
    Window rootWindow;
    int x, y;
    Window twin;
    int tabs; unsigned mask;
    //display = XOpenDisplay (NULL); 
    display = XOpenDisplay (":0"); 
    screen = DefaultScreen (display); 
    rootWindow = RootWindow (display, screen); 
    XQueryPointer(display, rootWindow,        
              &twin, &twin,                               
              &x, &y, &tabs, &tabs, &mask); 
    printf("mouse location: x:%d, y:%d\n", x, y);
    return 0;
}
